package ${package.ServiceImpl};

import ${package.Entity}.${entity};
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.${table.serviceName};
import ${superServiceImplClassPackage};
import org.springframework.stereotype.Service;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import com.common.project.util.ExcelUtiles;
/**
 * <p>
 * ${table.comment!} 服务实现类
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
@Service
<#if kotlin>
open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {

}
<#else>
@Log4j2
public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {

    @Override
    public String outPutMode(HttpServletResponse response) {
        String msg="";
        try {
            ExcelUtiles.exportExcel(new ArrayList<${entity}>(),"${table.comment}","${table.comment}",${entity}.class,"${table.comment}模板.xls",true,response);
            msg="导出成功";
        } catch (Exception e) {
            log.error("操作异常: "+e.getMessage(),e);
            msg="导出异常";
        }
        return msg;
    }

    @Override
    public boolean inPutMode(MultipartFile file, HttpServletRequest request) {
        if(file.isEmpty()){
            return false;
        }
        try {
            List<${entity}> ${entity}s = ExcelUtiles.importExcel(file, 0, 1, ${entity}.class);
            boolean save = this.saveBatch(${entity}s);
            return save;
        } catch (Exception e) {
            e.printStackTrace();
            log.error("操作异常: "+e.getMessage(),e);
            return false;
        }
    }

}
</#if>
